<template>
	<view class="my">
		<!-- 头部背景图片 -->
		<view class="top_images">
			<img src="/static/my/top_images.png" alt="">
		</view>
		<!-- 个人信息 -->
		<view class="info">
			<view class="attention">
				<view>
					<view>23</view>
					<view>礼物/获赞</view>
				</view>
				<view>
					<view>128</view>
					<view>粉丝</view>
				</view>
				<view>
					<view>23</view>
					<view>朋友</view>
				</view>
				<view>
					<view>233</view>
					<view>关注</view>
				</view>
			</view>
			<view class="information">
				<view class="information_info">
					<view class="headsculpture">
						<img src="" alt="">
					</view>
					<view class="info_name_title">
						<view class="info_name">小高喝酒</view>
						<view class="info_title">关注我了解更多酒水文化</view>
					</view>
					<view class="info_add">
						<view class="add">
							添加朋友
						</view>
					</view>
					<view class="grade">
						<img src="/static/my/grade.png" alt="">
					</view>
				</view>
			</view>
		</view>
		<view class="wallet_ofg">
			<view class="wallet">
				<view class="img">
					<img src="/static/my/wallet.png" alt="">
				</view>
				<view class="wallet_name">我的钱包</view>
			</view>
			<view class="ofg">
				<view class="img">
					<img src="/static/my/ofg.png" alt="">
				</view>
				<view class="ofg_name">我的订单</view>
			</view>
		</view>
		<view class="my_tab">
			<view class="my_tab_item">
				<view class="img"><img src="" alt=""></view>
				<view>开店必备</view>
			</view>
			<view class="my_tab_item">
				<view class="img"><img src="" alt=""></view>
				<view>企业合作</view>
			</view>
			<view class="my_tab_item">
				<view class="img"><img src="" alt=""></view>
				<view>商家入驻</view>
			</view>
			<view class="my_tab_item">
				<view class="img"><img src="" alt=""></view>
				<view>店铺管理</view>
			</view>
			<view class="my_tab_item">
				<view class="img"><img src="" alt=""></view>
				<view>金融服务</view>
			</view>
		</view>
		<view class="my_tabs">
			<view class="nav">
				<scroll-view class="tab-scroll" scroll-x="true" scroll-with-animation :scroll-into-view="tabCurrent">
					<view class="tab-scroll_box" style="display: flex; justify-content: space-between;">
						<!-- 选项卡类别列表 -->
						<view class="mt_tabs_items" v-for="(item, index) in tabsList" :key='(item.id - 1)'
							@tap="my_tabsBtn(item.id - 1)" :class="currIndex == (item.id - 1) ? 'active' : ''">
							{{item.name}}
						</view>
					</view>
				</scroll-view>
			</view>
			<swiper @change="swiperChange" :current="currIndex" class="swiper-content"
				:style="{height: (fullHeight * 2) + 'rpx'}">
				<swiper-item class="swiperitem-content">
					<scroll-view scroll-y style="height: 100%;">
						<view class="nav_item" style="display: flex; flex-wrap: wrap;">
							<view class="img"
								style="width: 247rpx; height: 360rpx; background-color: pink; border: 2rpx dotted #999999; position: relative;">
								<img src="" alt="">
								<view class="xi_box"
									style="width: 60rpx; position: absolute; bottom: 8rpx; right: 20rpx; display: flex; justify-content: space-around; align-items: center;">
									<img class="" src="/static/my/xihuan.png" alt=""
										style="width: 16rpx; height: 16rpx;">
									<view class="xi_num" style="font-size: 20rpx; color: #fff;">112</view>
								</view>
							</view>
							<view class="img"
								style="width: 247rpx; height: 360rpx; background-color: pink; border: 2rpx dotted #999999; position: relative;">
								<img src="" alt="">
								<view class="xi_box"
									style="width: 60rpx; position: absolute; bottom: 8rpx; right: 20rpx; display: flex; justify-content: space-around; align-items: center;">
									<img class="" src="/static/my/xihuan.png" alt=""
										style="width: 16rpx; height: 16rpx;">
									<view class="xi_num" style="font-size: 20rpx; color: #fff;">112</view>
								</view>
							</view>
							<view class="img"
								style="width: 247rpx; height: 360rpx; background-color: pink; border: 2rpx dotted #999999; position: relative;">
								<img src="" alt="">
								<view class="xi_box"
									style="width: 60rpx; position: absolute; bottom: 8rpx; right: 20rpx; display: flex; justify-content: space-around; align-items: center;">
									<img class="" src="/static/my/xihuan.png" alt=""
										style="width: 16rpx; height: 16rpx;">
									<view class="xi_num" style="font-size: 20rpx; color: #fff;">112</view>
								</view>
							</view>
							<view class="img"
								style="width: 247rpx; height: 360rpx; background-color: pink; border: 2rpx dotted #999999; position: relative;">
								<img src="" alt="">
								<view class="xi_box"
									style="width: 60rpx; position: absolute; bottom: 8rpx; right: 20rpx; display: flex; justify-content: space-around; align-items: center;">
									<img class="" src="/static/my/xihuan.png" alt=""
										style="width: 16rpx; height: 16rpx;">
									<view class="xi_num" style="font-size: 20rpx; color: #fff;">112</view>
								</view>
							</view>
							<view class="img"
								style="width: 247rpx; height: 360rpx; background-color: pink; border: 2rpx dotted #999999; position: relative;">
								<img src="" alt="">
								<view class="xi_box"
									style="width: 60rpx; position: absolute; bottom: 8rpx; right: 20rpx; display: flex; justify-content: space-around; align-items: center;">
									<img class="" src="/static/my/xihuan.png" alt=""
										style="width: 16rpx; height: 16rpx;">
									<view class="xi_num" style="font-size: 20rpx; color: #fff;">112</view>
								</view>
							</view>
							<view class="img"
								style="width: 247rpx; height: 360rpx; background-color: pink; border: 2rpx dotted #999999; position: relative;">
								<img src="" alt="">
								<view class="xi_box"
									style="width: 60rpx; position: absolute; bottom: 8rpx; right: 20rpx; display: flex; justify-content: space-around; align-items: center;">
									<img class="" src="/static/my/xihuan.png" alt=""
										style="width: 16rpx; height: 16rpx;">
									<view class="xi_num" style="font-size: 20rpx; color: #fff;">112</view>
								</view>
							</view>
							<view class="img"
								style="width: 247rpx; height: 360rpx; background-color: pink; border: 2rpx dotted #999999; position: relative;">
								<img src="" alt="">
								<view class="xi_box"
									style="width: 60rpx; position: absolute; bottom: 8rpx; right: 20rpx; display: flex; justify-content: space-around; align-items: center;">
									<img class="" src="/static/my/xihuan.png" alt=""
										style="width: 16rpx; height: 16rpx;">
									<view class="xi_num" style="font-size: 20rpx; color: #fff;">112</view>
								</view>
							</view>
						</view>
					</scroll-view>
				</swiper-item>
				<swiper-item class="swiperitem-content">
					<scroll-view scroll-y style="height: 100%;">
						<view class="nav_item">
							<view class="hovertree-trackrcol">
								<view class="hovertree-tracklist">
									<view>
										<view class="steps">
											<view class="time_title">
												<view class="time">
													2022.01.22 
												</view>
												<view class="title">
													遇见
												</view>
											</view>
											<view class="steps_item first">
												<view class="node-icon"></view>
												<view class="text">
													累计陪你走过302天
												</view>
											</view>
										</view>
										<view class="steps">
											<view class="time_title">
												<view class="time">
													2022.01.29 12:30
												</view>
												<view class="title">
													又将故事藏于酒里
												</view>
											</view>
											<view class="steps_item">
												<view class="node-icon"></view>
												<view class="text">
													<view class="img">
														<img src="" alt="">
													</view>
													<view class="txt">
														飞天茅台53度 500ml
													</view>
												</view>
											</view>
										</view>
										<view class="steps">
											<view class="time_title">
												<view class="time">
													2022.05.30 12:30
												</view>
												<view class="title">
													【婚礼婚宴】
												</view>
												<view class="content">
													人生大事与爱的人成家！
												</view>
											</view>
											<view class="steps_item">
												<view class="node-icon"></view>
												<view class="text">
													<view class="img">
														<img src="" alt="">
													</view>
												</view>
											</view>
										</view>
										<view class="steps">
											<view class="time_title">
												<view class="time">
													2022.05.30 12:30
												</view>
												<view class="title">
													【宝宝百日宴】
												</view>
												<view class="content">
													我们的宝宝一百天啦
												</view>
											</view>
											<view class="steps_item">
												<view class="node-icon"></view>
												<view class="text">
													<view class="img">
														<img src="" alt="">
													</view>
												</view>
											</view>
										</view>
										
										
										<view class="steps">
											<view class="time_title">
												<view class="time">
													2022.05.30 12:30
												</view>
												<view class="title">
													【寿宴】
												</view>
												<view class="content">
													祝福妈妈！！
												</view>
											</view>
											<view class="steps_item">
												<view class="node-icon"></view>
												<view class="text">
													<view class="img">
														<img src="" alt="">
													</view>
												</view>
											</view>
										</view>
									</view>
								</view>
							</view>
						</view>
					</scroll-view>
				</swiper-item>
				<swiper-item class="swiperitem-content">
					<scroll-view scroll-y style="height: 100%;">
						<view class="nav_item">
							选项卡3页面
						</view>
					</scroll-view>
				</swiper-item>
				<swiper-item class="swiperitem-content">
					<scroll-view scroll-y style="height: 100%;">
						<view class="nav_item">
							选项卡4页面
						</view>
					</scroll-view>
				</swiper-item>
				<swiper-item class="swiperitem-content">
					<scroll-view scroll-y style="height: 100%;">
						<view class="nav_item">
							选项卡5页面
						</view>
					</scroll-view>
				</swiper-item>
				<swiper-item class="swiperitem-content">
					<scroll-view scroll-y style="height: 100%;">
						<view class="nav_item">
							选项卡6页面
						</view>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>

<script>
	const http = require('../../utils/http')
	const cartCount = require('../../utils/cart-count.js')
	export default {
		data() {
			return {
				isNotLogged: true, // 未登录
				userInfo: '',
				orderCountInfo: '',
				simpleInfo: '',
				tabsList: [{
						name: '作品',
						id: 1
					},
					{
						name: '成长',
						id: 2
					},
					{
						name: '私密',
						id: 3
					},
					{
						name: '圈子',
						id: 4
					},
					{
						name: '喜欢',
						id: 5
					},
					{
						name: '收藏',
						id: 6
					},
				],
				currIndex: 0,
				tabCurrent: 'tabNum1',
				swiperHeight: 0,
				fullHeight: {
					height: 1400
				}
			}
		},
		mounted() {
			var that = this;
			//获取手机屏幕的高度，让其等于swiper的高度，从而使屏幕充满
			uni.getSystemInfo({
				success: function(res) {
					console.log(res, '========>res')
					that.fullHeight = res.windowHeight
					console.log(that.fullHeight, '==============>高 ')
				}
			});
		},
		onShow() {
			// 排除 tempToken 影响，真实登陆后再请求数据
			if (uni.getStorageSync('token')) {
				// 查询用户信息
				this.queryUserInfo()
				// 加载订单数据
				this.loadOrderCountFun()
				// 获取用户头像昵称
				this.getSimpleInfo()
				this.isNotLogged = false
			} else {
				this.simpleInfo = {}
				this.orderCountInfo = {}
				this.userInfo = {}
				this.isNotLogged = true
			}
			cartCount.getCartCount()
		},

		methods: {
			// 获取标题区域宽度，和每个子元素节点的宽度以及元素距离左边栏的距离
			getScrollW() {
				const query = uni.createSelectorQuery().in(this);
				query.select('.tab-scroll').boundingClientRect(data => {
					// 拿到 scroll-view 组件宽度
					this.contentScrollW = data.width
				}).exec();
				query.selectAll('.tab-scroll_item').boundingClientRect(data => {
					let dataLen = data.length;
					for (let i = 0; i < dataLen; i++) {
						//  scroll-view 子元素组件距离左边栏的距离
						this.category[i].left = data[i].left;
						//  scroll-view 子元素组件宽度
						this.category[i].width = data[i].width
					}
				}).exec()
			},
			/**
			 * 获取用户昵称头像
			 */
			getSimpleInfo() {
				const params = {
					url: '/gscloud_user/a/user/simple_info',
					method: 'GET',
					data: {},
					callBack: res => {
						this.simpleInfo = res
					}
				}
				http.request(params)
			},

			/**
			 * 获取用户信息
			 */
			queryUserInfo() {
				const params = {
					url: '/gscloud_user/a/user/ma/user_detail_info',
					method: 'GET',
					data: {},
					callBack: res => {
						this.userInfo = res
					}
				}
				http.request(params)
			},

			// 去登陆
			toLogin() {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			},

			// 去用户设置
			toUserSettings() {
				uni.navigateTo({
					url: '/pages/user-settings/user-settings'
				})
			},

			// 去我的余额
			toMyBalance() {
				uni.navigateTo({
					url: '/pages/my-balance/my-balance'
				})
			},

			// 去我的订单
			toMyOder(sts) {
				uni.navigateTo({
					url: '/pages/order/order?orderStatus=' + sts
				})
			},
			// 去地址管理
			toAddressList() {
				uni.navigateTo({
					url: '/pages/address-list/address-list'
				})
			},
			//去我的收藏
			tomyCollect() {
				uni.navigateTo({
					url: '/wine/myCollect/myCollect'
				})
			},
			//去酒企入驻
			toWinery() {
				uni.navigateTo({
					url: '/wine/winery/winery'
				})
			},
			// 去免费开店
			toFreeShop() {
				if (uni.getStorageSync('token')) {
					console.log('跳转到免费开店')
					uni.navigateTo({
						url: '/pages/free-shop/free-shop'
					})
				} else {
					uni.showToast({
						title: '请登录账号',
						duration: 2000,
						icon: 'error'
					})
					setTimeout(() => {
						uni.navigateTo({
							url: '/'
						})
					}, 2000)
				}
			},
			notOpen(title) {
				uni.showModal({
					title: '提示',
					content: `${title}暂未开源`,
					showCancel: false,
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定')
						} else if (res.cancel) {
							console.log('用户点击取消')
						}
					}
				})
			},
			my_tabsBtn(id) {
				this.currIndex = id
				this.currentTab = id
				this.tabCurrent = 'tabNum' + id
			},
			swichMenu(id) {},
			swiperChange(e) {
				let index = e.detail.current
				this.my_tabsBtn(index)
			},
			//动态设置swiper的高度
			setSwiperHeight() {
				let element = "#content-wrap" + this.currentIndex;
				let query = uni.createSelectorQuery().in(this);
				query.select(element).boundingClientRect();
				query.exec((res) => {
					if (res && res[0]) {
						this.swiperHeight = res[0].height;
					}
				});
			},
		}
	}
</script>

<style>
	@import "./my.css";
</style>